<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends Front_Controller {
 	var $siteSetings;
	var $announcement;
	var $lineclass;   
	var $des_tags;		//目的地标签   
	var $TicketClass;
	var $newsclass;
	var $strategy;
	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form'));
		$this->load->model('front/Frontget_ml');
		$this->load->model('front/Search_m');
		$this->load->model('front/News_cate_m');
		$this->load->model('front/Hotel_mdl');
	//	$this->output->enable_profiler(true);
		$this->load->model('front/Ticket_m');	
		$this->load->model('front/City_mdl');
		$this->load->model('front/Price_mdl');
		$this->siteSetings=$this->Frontget_ml->get_site_settings();	//获取站点设置
		$this->announcement=$this->Frontget_ml->get_announcement();	//获取网站公告		
		$this->lineclass=$this->Frontget_ml->get_lineclass();//获取线路分类
		$this->TicketClass=$this->Frontget_ml->getTicketClass();//获取汽车分类
		$this->newsclass=$this->Frontget_ml->get_newsclass();//获取汽车分类
		$this->strategy=$this->Frontget_ml->get_tagsclass();//获取攻略分类
		$this->des_tags=$this->Search_m->get_des_tags();	//获取标签分类
		$this->friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
		$this->CityClass=$this->Frontget_ml->getCityClass();//获取城市分类
	//	$this->load->library('form_validation');	
	}

	public function index()
	{		 
		$ticketModel=19;
		$line_annex=$this->Frontget_ml->get_line_annex();							//获取线路图片附件
	//	$right_lines=$this->Frontget_ml->get_right_lines();							//获取右侧热门线路
		$indexpage_lines=$this->Frontget_ml->get_indexpage_lines($this->lineclass);	//获取线路列表
		$IndexGuide=$this->Frontget_ml->getIndexGuide($this->strategy);				//获取温泉攻略分类列表
	//	$commend_lines=$this->Frontget_ml->get_commend_lines();						//获取推荐线路列表
	    $RecommendList=$this->Ticket_m->getCommendTicket($ticketModel,10);			//获取推荐门票
	    $HotTicketList=$this->Ticket_m->getHotTicket($ticketModel,10);				//获取热门门票
	    $LastTicketList=$this->Ticket_m->getLastTicket($ticketModel,10);			//获取最新门票		
		$slider_lines=$this->Frontget_ml->get_slider_lines();						//获取幻灯片
		$friend_links=$this->Frontget_ml->get_friend_links();						//获取友情链接
		$topHotelList = $this->Hotel_mdl->getHotelInfoByType("hotel_top");	//获取推荐酒店
		$current_title=$this->siteSetings["site_description"];
		$TopNewsList=$this->News_cate_m->getTopNewsList();							//温泉动态
		$LastTicketList1=$this->Ticket_m->getIndexLastTicket($ticketModel);				//获取最新订单
		$city  = $this->City_mdl->getCityList();										//城市分类
		$price = $this->Price_mdl->getPriceList();
		$data=array("topHotelList"=>$topHotelList,"RecommendList"=>$RecommendList,"HotTicketList"=>$HotTicketList,"LastTicketList"=>$LastTicketList,"LastTicketList1"=>$LastTicketList1,"IndexGuide"=>$IndexGuide,"TopNewsList"=>$TopNewsList,"current_title"=>$current_title,"tagsclass"=>$this->strategy,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"slider_lines"=>$slider_lines,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"indexpage_lines"=>$indexpage_lines,"announcement"=>$this->announcement,"friend_links"=>$friend_links,"des_tags"=>$this->des_tags);
		$data += $city;
		$data += $price;
		$this->load->view('main_v',$data);
	}
	public function flashXml_v(){
		$slider_lines=$this->Frontget_ml->get_slider_lines();//获取幻灯片
		$data=array("slider_lines"=>$slider_lines);
		$this->load->view('flashXml_v',$data);
	}
	public  function category($parentid=1){	//for ajax 显示子类
		 
		$classname=$this->Frontget_ml->get_subclass($parentid);	//获取子类
		$subClassList="";
		//$base_url=base_url();
		foreach($classname as $key){		
			$subClassList.= "<a href='".base_url()."main/category_list/$key->classid'>$key->classname</a>";
		}
		echo $subClassList;
	}
	public  function category_list($cateid=0){	//旅游线路分类页
		if((int)$cateid){
			$this->load->model('front/Category_m');
				$slider_lines=$this->Frontget_ml->get_slider_lines($cateid);//获取幻灯片
				$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
				$commend_lines=$this->Frontget_ml->get_commend_lines($cateid);//获取推荐线路列表
				if(!empty($this->lineclass["parentid"][$cateid])){
					$category_list=$this->Category_m->get_category_list($cateid,$this->lineclass["parentid"][$cateid]);//获取分类线路列表
				}else{
					$category_list=null;
				}
		//	print_r($slider_lines);	
			$commend_lines=$this->Frontget_ml->get_commend_lines();	//获取推荐线路列表
			$HotLineList=$this->Frontget_ml->getHotLineList();		//获取推荐线路列表
			$LastLineList=$this->Frontget_ml->getLastLineList();		//获取推荐线路列表
			$slider_lines=$this->Frontget_ml->get_slider_lines();		//获取幻灯片线路列表
			$indexpage_lines=$this->Frontget_ml->get_indexpage_lines($this->lineclass);//获取线路列表
			$IndexGuide=$this->Frontget_ml->getIndexGuide($this->strategy);				//获取温泉攻略分类列表
			$current_title=$this->lineclass["classname"][$cateid];
			$data=array("IndexGuide"=>$IndexGuide,"indexpage_lines"=>$indexpage_lines,"slider_lines"=>$slider_lines,"LastLineList"=>$LastLineList,"HotLineList"=>$HotLineList,"commend_lines"=>$commend_lines,"current_title"=>$current_title,"tagsclass"=>$this->strategy,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"cateid"=>$cateid,"commend_lines"=>$commend_lines,"slider_lines"=>$slider_lines,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"cateid"=>$cateid,"category_list"=>$category_list,"announcement"=>$this->announcement,"friend_links"=>$friend_links);		
			$this->load->view('inc/header',$data);
			$this->load->view('catepage_v');
			
		}else{
			redirect(base_url());	//参数错误
		}
	}	
	public  function subclass($cateid=0){	//旅游线路分类页
		if((int)$cateid){
			$this->load->model('front/Category_m');
			$slider_lines=$this->Frontget_ml->get_slider_lines($cateid);//获取幻灯片
			$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
		//	$commend_lines=$this->Frontget_ml->get_commend_lines($cateid);//获取推荐线路列表
			//分页
			$this->load->library('pagination');
			$config['base_url'] = site_url('/main/subclass/'.$cateid.'/');
			
			$total_rows= $this->Frontget_ml->get_art_num($cateid);//获取查询条件下的记录总数
			$config['total_rows'] =$total_rows[0];
		//			print_r($config['total_rows']);
			$config['per_page'] = 10;
			$config['uri_segment'] = 4;
			$config['full_tag_open'] = '';
			$config['full_tag_close'] = '';
			$config['cur_tag_open']= '&nbsp;<span class="current">';
			$config['cur_tag_close']= '</span>';
			$config['prev_link']= '上一页';
			$config['next_link']= '下一页';
			$config['first_link']= ' 首页';
			$config['last_link']= ' 尾页';
			//	$config['use_page_numbers'] = TRUE;
			$this->pagination->initialize($config);
			$begin_record=$this->uri->segment(4);
			//分页end			
			$subclass_list=$this->Category_m->get_subclass_list($cateid,$begin_record,$config['per_page']);//获取分类线路列表
				
			$current_title=$this->lineclass["classname"][$cateid];
			$data=array("current_title"=>$current_title,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"cateid"=>$cateid,"slider_lines"=>$slider_lines,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"cateid"=>$cateid,"subclass_list"=>$subclass_list,"announcement"=>$this->announcement,"friend_links"=>$friend_links);
			$this->load->view('inc/header',$data);
			$this->load->view('subclass_v');
				
		}else{
			redirect(base_url());	//参数错误
		}
	}	
	public  function line_show($lineId){	//获取指定id文章信息
		if((int)$lineId){	
		//	$right_lines=$this->Frontget_ml->get_right_lines();//获取左侧热门线路
			$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
			$lineInfo=$this->Frontget_ml->get_lineInfo($lineId);	//获取指定id文章信息
			$cateid=explode("-",str_replace(",","",$lineInfo['list'][0]->line_class));//文章类id
		//	print_r($cateid);
		//	print_r($lineInfo);		
			$current_title=$lineInfo['list'][0]->trav_title;
			$data=array("current_title"=>$current_title,"tagsclass"=>$this->strategy,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"lineId"=>$lineId,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"lineInfo"=>$lineInfo,"cateid"=>$cateid,"announcement"=>$this->announcement,"friend_links"=>$friend_links);
		
			$this->load->view('inc/header',$data);
			$this->load->view('line_show');	
		}else{
			redirect(base_url());	//参数错误
		}	
	}
	public  function lineSearch(){	//按条件查询温泉线路
		$StartDate   = $this->uri->segment(3);
		$EndDate  	 = $this->uri->segment(4);
		$txtKeyName  = $this->uri->segment(5);
		$txtKeyName=rawurldecode($txtKeyName);
		$this->load->library('pagination');
		$config['base_url'] = site_url("/main/lineSearch/$StartDate/$EndDate/$txtKeyName/");
	
		$totalRows= $this->Frontget_ml->getLineSearch($StartDate,$EndDate,$txtKeyName,0);//获取查询条件下的记录总数
		$config['total_rows'] =$totalRows;
		// print_r($total_rows);
		$config['per_page'] = 10;
		$config['uri_segment'] = 6;
		$config['full_tag_open'] = '';
		$config['full_tag_close'] = '';
		$config['cur_tag_open']= '&nbsp;<span class="current">';
		$config['cur_tag_close']= '</span>';
		$config['prev_link']= '上一页';
		$config['next_link']= '下一页';
		$config['first_link']= ' 首页';
		$config['last_link']= ' 尾页';
		//	$config['use_page_numbers'] = TRUE;
		$this->pagination->initialize($config);
		$begin_record=$this->uri->segment(6);
		if(!$begin_record){
			$begin_record=0;
		}
		//分页end
		$LineSearchList=$this->Frontget_ml->getLineSearch($StartDate,$EndDate,$txtKeyName,1,$begin_record,$config['per_page']);//获取分类线路列表
	
		$current_title="线路查询";
		$data=array("current_title"=>$current_title,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"tagsclass"=>$this->strategy,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"LineSearchList"=>$LineSearchList,"announcement"=>$this->announcement,"friend_links"=>$this->friend_links);
		$this->load->view('inc/header',$data);
		$this->load->view('lineSearch_v');
	}
}
/* End of file main.php */
/* Location: ./application/controllers/main.php */